home *** CD-ROM | disk | FTP | other *** search
/ Game.EXE 2001 January / execd1200.iso / Shareware / Blocks 3 / setup.exe / Source / CDPLAY.C < prev    next >
Encoding:
C/C++ Source or Header  |  2000-10-05  |  6.2 KB  |  243 lines

  1. #include <allegro.h>
  2. #include <jgmod.h>
  3. #include <libcda.h>
  4. #include <blocks3.h>
  5.  
  6. int cd_track = -1;
  7.  
  8. void CD_Player(void)
  9. {
  10.  BITMAP *temp2 = create_bitmap(200, 300);
  11.  BITMAP *temp3 = create_bitmap(640, 480);
  12.  
  13.  int cd_exit, item;
  14.  int first, last, i;
  15.  
  16.  cd_exit = 0;
  17.  item = 0;
  18.  
  19.  blit(screen, temp3, 0, 0, 0, 0, 640, 480);
  20.  rect(temp2, 0, 0, 199, 299, 0);
  21.  
  22.  rectfill(temp2, 1, 1, 198, 298, 7);
  23.  rectfill(temp2, 10, 10, 189, 20, makecol(128, 128, 128));
  24.  rectfill(temp2, 10, 279, 189, 289, makecol(128, 128, 128));
  25.  rect(temp2, 10, 10, 189, 20, 0);
  26.  rect(temp2, 10, 279, 189, 289, 0);
  27.  
  28.  rectfill(temp2, 10, item*40 + 50, 190, item*40 + 80, makecol(180, 180, 255));
  29.  text_mode(-1);
  30.  
  31.  if (cd_track == -1) textprintf_centre(temp2, fonts[0].dat, 100, 50,  0, "Play");
  32.  else textprintf_centre(temp2, fonts[0].dat, 100, 50,  0, "Stop");
  33.  
  34.  textprintf_centre(temp2, fonts[0].dat, 100, 90, 0, "Next");
  35.  textprintf_centre(temp2, fonts[0].dat, 100, 130, 0, "Previous");
  36.  textprintf_centre(temp2, fonts[0].dat, 100, 170, 0, "Eject");
  37.  textprintf_centre(temp2, fonts[0].dat, 100, 210, 0, "Exit");
  38.  
  39.  for (i = -200; i < 230; i+=10)
  40.  {
  41.   blit(temp3, screen, i - 10, 100, i-10, 100, 10, 300);
  42.   blit(temp2, screen, 0, 0, i, 100, 200, 300);
  43.   while (time_count < 1);
  44.   time_count = 0;
  45.  }
  46.  
  47.  while(!cd_exit)
  48.  {
  49.   rectfill(temp2, 1, 1, 198, 298, 7);
  50.   rectfill(temp2, 10, 10, 189, 20, makecol(128, 128, 128));
  51.   rectfill(temp2, 10, 279, 189, 289, makecol(128, 128, 128));
  52.   rect(temp2, 10, 10, 189, 20, 0);
  53.   rect(temp2, 10, 279, 189, 289, 0);
  54.  
  55.   rectfill(temp2, 10, item*40 + 50, 190, item*40 + 80, makecol(180, 180, 255));
  56.   text_mode(-1);
  57.  
  58.   if (cd_track == -1) textprintf_centre(temp2, fonts[0].dat, 100, 50,  0, "Play");
  59.   else textprintf_centre(temp2, fonts[0].dat, 100, 50,  0, "Stop");
  60.  
  61.   textprintf_centre(temp2, fonts[0].dat, 100, 90, 0, "Next");
  62.   textprintf_centre(temp2, fonts[0].dat, 100, 130, 0, "Previous");
  63.   textprintf_centre(temp2, fonts[0].dat, 100, 170, 0, "Eject");
  64.   textprintf_centre(temp2, fonts[0].dat, 100, 210, 0, "Exit");
  65.  
  66.   blit(temp2, screen, 0, 0, 220, 100, 200, 300);
  67.  
  68.   while ((!key[KEY_ESC]) && (!key[KEY_UP]) && (!key[KEY_DOWN]) && (!key[KEY_ENTER]));
  69.  
  70.   if (key[KEY_ESC]) cd_exit = 1;
  71.  
  72.   if (key[KEY_ENTER])
  73.   {
  74.    if (item == 4) cd_exit = 1;
  75.    if (item == 3)
  76.    {
  77.     cd_eject();
  78.     cd_track = -1;
  79.    }
  80.  
  81.    if (item == 0)
  82.    {
  83.     if (cd_track != -1)
  84.     {
  85.      cd_stop();
  86.      cd_track = -1;
  87.     }
  88.     else
  89.     {
  90.      if (cd_play_from(1) != -1) cd_track = 1;
  91.     }
  92.    }
  93.  
  94.    if (item == 1)
  95.    {
  96.     cd_get_tracks(&first, &last);
  97.     cd_track = cd_current_track();
  98.  
  99.     cd_track++;
  100.  
  101.     if (cd_track > last) cd_track = first;
  102.  
  103.     if (cd_play_from(cd_track) == -1) cd_track = -1;
  104.  
  105.     text_mode(0);
  106.     textprintf(screen, font, 10, 10, 7, "%d ", cd_track);
  107.    }
  108.  
  109.    if (item == 2)
  110.    {
  111.     cd_get_tracks(&first, &last);
  112.     cd_track = cd_current_track();
  113.  
  114.     cd_track--;
  115.  
  116.     if (cd_play_from(cd_track) == -1) cd_track = -1;
  117.  
  118.     text_mode(0);
  119.     textprintf(screen, font, 10, 10, 7, "%d ", cd_track);
  120.    }
  121.  
  122.    play_sample(sfx[SFX_FALL].dat, 255, 128, 1000, 0);
  123.   }
  124.   else play_sample(sfx[SFX_CLICK].dat, 255, 128, 1000, 0);
  125.  
  126.   if (key[KEY_UP]) item--;
  127.   if (key[KEY_DOWN]) item++;
  128.  
  129.   if (item < 0) item = 4;
  130.   if (item > 4) item = 0;
  131.  
  132.   while ((key[KEY_ESC]) || (key[KEY_UP]) || (key[KEY_DOWN]) || (key[KEY_ENTER]));
  133.  }
  134.  
  135.  for (i = 220; i < 650; i+=10)
  136.  {
  137.   blit(temp3, screen, i - 10, 100, i-10, 100, 10, 300);
  138.   blit(temp2, screen, 0, 0, i, 100, 200, 300);
  139.   while (time_count < 1);
  140.   time_count = 0;
  141.  }
  142.  
  143.  blit(temp3, screen, 0, 0, 0, 0, 640, 480);
  144. }
  145.  
  146. void Mod_Music(void)
  147. {
  148.  BITMAP *temp2 = create_bitmap(200, 300);
  149.  BITMAP *temp3 = create_bitmap(640, 480);
  150.  
  151.  int cd_exit, item;
  152.  int first, last, i;
  153.  
  154.  cd_exit = 0;
  155.  item = 0;
  156.  
  157.  blit(screen, temp3, 0, 0, 0, 0, 640, 480);
  158.  rect(temp2, 0, 0, 199, 189, 0);
  159.  
  160.  rectfill(temp2, 1, 1, 198, 188, 7);
  161.  rectfill(temp2, 10, 10, 189, 20, makecol(128, 128, 128));
  162.  rectfill(temp2, 10, 170, 189, 180, makecol(128, 128, 128));
  163.  rect(temp2, 10, 10, 189, 20, 0);
  164.  rect(temp2, 10, 170, 189, 180, 0);
  165.  
  166.  rectfill(temp2, 10, item*40 + 40, 190, item*40 + 70, makecol(180, 180, 255));
  167.  text_mode(-1);
  168.  
  169.  textprintf_centre(temp2, fonts[0].dat, 100, 40, 0, "Next");
  170.  textprintf_centre(temp2, fonts[0].dat, 100, 80, 0, "Previous");
  171.  textprintf_centre(temp2, fonts[0].dat, 100, 120, 0, "Return");
  172.  
  173.  for (i = -200; i < 230; i+=10)
  174.  {
  175.   blit(temp, screen, i - 10, 100, i-10, 100, 10, 190);
  176.   blit(temp2, screen, 0, 0, i, 100, 200, 190);
  177.   while (time_count < 1);
  178.   time_count = 0;
  179.  }
  180.  
  181.  cd_exit = 0;
  182.  item = 0;
  183.  
  184.  while (!cd_exit)
  185.  {
  186.   rectfill(temp2, 1, 1, 198, 188, 7);
  187.   rectfill(temp2, 10, 10, 189, 20, makecol(128, 128, 128));
  188.   rectfill(temp2, 10, 170, 189, 180, makecol(128, 128, 128));
  189.   rect(temp2, 10, 10, 189, 20, 0);
  190.   rect(temp2, 10, 170, 189, 180, 0);
  191.  
  192.   rectfill(temp2, 10, item*40 + 40, 190, item*40 + 70, makecol(180, 180, 255));
  193.   text_mode(-1);
  194.  
  195.   textprintf_centre(temp2, fonts[0].dat, 100, 40,  0, "Next");
  196.   textprintf_centre(temp2, fonts[0].dat, 100, 80, 0, "Previous");
  197.   textprintf_centre(temp2, fonts[0].dat, 100, 120, 0, "Return");
  198.  
  199.   blit(temp2, screen, 0, 0, 220, 100, 200, 190);
  200.  
  201.   while ((!key[KEY_ESC]) && (!key[KEY_UP]) && (!key[KEY_DOWN]) && (!key[KEY_ENTER]));
  202.  
  203.   if (key[KEY_ESC]) cd_exit = 1;
  204.  
  205.   if (key[KEY_ENTER])
  206.   {
  207.    if (item != 2)
  208.    {
  209.     if (item == 0) mod_track++;
  210.     if (item == 1) mod_track--;
  211.  
  212.     if (mod_track < 0) mod_track = mod_last;
  213.     if (mod_track > mod_last) mod_track = 0;
  214.  
  215.     music = load_mod(mod[mod_track].name);
  216.     play_mod(music, TRUE);
  217.    }
  218.    else cd_exit = 1;
  219.  
  220.    play_sample(sfx[SFX_FALL].dat, 255, 128, 1000, 0);
  221.   }
  222.   else play_sample(sfx[SFX_CLICK].dat, 255, 128, 1000, 0);
  223.  
  224.   if (key[KEY_UP]) item--;
  225.   if (key[KEY_DOWN]) item++;
  226.  
  227.   if (item < 0) item = 2;
  228.   if (item > 2) item = 0;
  229.  
  230.   while ((key[KEY_ESC]) || (key[KEY_UP]) || (key[KEY_DOWN]) || (key[KEY_ENTER]));
  231.  }
  232.  
  233.  for (i = 220; i < 650; i+=10)
  234.  {
  235.   blit(temp3, screen, i - 10, 100, i-10, 100, 10, 190);
  236.   blit(temp2, screen, 0, 0, i, 100, 200, 190);
  237.   while (time_count < 1);
  238.   time_count = 0;
  239.  }
  240.  
  241.  blit(temp3, screen, 0, 0, 0, 0, 640, 480);
  242. }
  243.